import 'package:get/get.dart';
import 'package:xinxuan/http/http_util_service.dart';
import 'package:xinxuan/vo/article_detail_vo.dart';

class ArticleDetailPageController extends GetxController {

  /// 文章详情
  var articleDetailData = ArticleDetailData(content: '').obs;

  @override
  void onReady() {
    Map<String, dynamic> argumentsMap = Get.arguments;
    int articleId = argumentsMap['articleId'];
    getArticleDetail(articleId);
    super.onReady();
  }

  /// 获取文章详情
  getArticleDetail(int articleId) async {
    ArticleDetailVo articleDetailVo = await HttpUtilService.getArticleDetail(articleId: articleId);
    articleDetailData.value = articleDetailVo.data!;
    Future.delayed(Duration(milliseconds: 100), () {
      update();
    });
  }

}